package com.gidgabs.modules.api.controller.my;

import com.gidgabs.common.annotation.LoginUserApi;
import com.gidgabs.common.utils.ReturnJson;
import com.gidgabs.common.validator.Assert;
import com.gidgabs.dto.TbUserDto;
import com.gidgabs.dto.TbUserIncomeDto;
import com.gidgabs.modules.api.service.my.MyUserService;
import com.gidgabs.modules.entity.TbUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by tby on 2018/7/4.
 */
@Api("我的模块")
@RestController
@RequestMapping("api/my")
public class ApiMyController {
    @Autowired private MyUserService myUserService;

    @ApiOperation(value = "获取用户/商户详细信息(包含转发量,粉丝,关注其他人的数量)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "用户id,为空时查询当前登录人信息",dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "token",value = "token",dataType = "string",paramType = "header")
    })
    @RequestMapping(value = "user", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public ReturnJson<TbUserDto> userDetail(Integer  userId) {

        return myUserService.userDetail(userId);
    }

    @ApiOperation(value = "个人信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token",value = "token",dataType = "string",paramType = "header")
    })
    @RequestMapping(value = "user", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public ReturnJson<TbUserDto> deitUser(@ModelAttribute TbUserDto tbUserDto ) {

        return myUserService.deitUser(tbUserDto);
    }


    @ApiOperation(value = "钱包统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token",value = "token",dataType = "string",paramType = "header")
    })
    @RequestMapping(value = "wallet", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public ReturnJson wallet() {
        return myUserService.wallet();
    }

    @ApiOperation(value = "钱包明细记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize",value = "页面大小",dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageNo",value = "页码",dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "revenueType",value = "类型: 跑腿:RUN_LEG,日志打赏:JOURNAL_REWARD,日志转载:JOURNAL_REPRINT,产品:RPODUCT",dataType = "string",paramType = "query"),
            @ApiImplicitParam(name = "token",value = "token",dataType = "string",paramType = "header")
    })
    @RequestMapping(value = "wallet/list", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public ReturnJson<TbUserIncomeDto> walletList(Integer pageSize, Integer pageNo, String revenueType) {
        return myUserService.walletList(pageSize,pageNo,revenueType);
    }

}
